package cn.example.vip.mall.goods.feign;

import cn.example.vip.mall.cart.entity.Cart;
import cn.example.vip.mall.goods.entity.Sku;
import cn.example.vip.mall.util.RespResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "mall-goods", path = "/sku", contextId = "mall-goods-sku")
public interface SkuFeign {
	
	/**
	 * 根据Id查询商品信息
	 */
	@GetMapping("/{id}")
	RespResult<Sku> querySkuById(@PathVariable("id") String id);
	
	/**
	 * 根据type查询AdItems
	 * @param type
	 * @return
	 */
	@GetMapping("/adItems/{type}")
	List<Sku> typeItems(@PathVariable("type") Integer type);
	
	/**
	 * 根据type删除AdItems缓存
	 * @param type
	 * @return
	 */
	@DeleteMapping("/adItems/{type}")
	RespResult delTypeItems(@RequestParam("type") Integer type);
	
	/**
	 * 根据type查询AdItems并更新缓存
	 * @param type
	 * @return
	 */
	@PutMapping("/adItems/{type}")
	RespResult updateTypeItems(@PathVariable("type") Integer type);
	
	/**
	 * 库存递减
	 * @param carts
	 * @return
	 */
	@PostMapping("/dcount")
	RespResult dcount(@RequestBody List<Cart> carts);
}
